package com.ccys.doctor.controller;

import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.dto.doctor.doctorConsultStage.*;
import com.ccys.db.vo.doctor.doctorConsultStage.*;
import com.ccys.doctor.service.DoctorConsultStageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * @program: WhiteCoat
 * @description: Consult Stage
 * @author: ZhangJingCan
 * @create: 2024-02-24 09:36
 **/

@Slf4j
@RestController
@RequestMapping("/doctorConsultStage")
@Api(tags = "DoctorConsultStage")
public class DoctorConsultStageController {

    @Autowired
    private DoctorConsultStageService doctorConsultStageService;

    /**
     * Needed booking_id,
     * Indo GP doctor approve the SG doctor medication with the Indo patient. Only in indo flow
     *
     * @param bookingId
     * @return
     */
    @ApiOperation("批准药物")
    @GetMapping(value = "/ApproveMedications")
    public ResponseResultApp approveMedications(String bookingId) {
        return doctorConsultStageService.approveMedications(bookingId);
    }

    @GetMapping(value = "/CheckProductAvailableForIndonesia")
    public ResponseResultApp checkProductAvailableForIndonesia(@RequestBody CheckProductAvailableDto dto){
        return ResponseResultApp.success(doctorConsultStageService.checkProductAvailableForIndonesia(dto));
    }


    @ApiOperation("检查原始booking中的药物数量是否可用")
    @PostMapping(value = "/CheckQuantityForRepeat")
    public ResponseResultApp checkQuantityForRepeat(@RequestBody CheckQuantityForAddFavouriteDto dto){
        return doctorConsultStageService.checkQuantityForRepeat(dto);
    }

    @ApiOperation("检查包装内药物的数量")
    @GetMapping(value = "/CheckQuantityMedicationInPackage")
    public ResponseResultApp<List<CheckQuantityMedicationInPackageVo>> checkQuantityMedicationInPackage(String packageId) {
        return doctorConsultStageService.checkQuantityMedicationInPackage(packageId);
    }

    @ApiOperation("检查包装内药物的数量")
    @PostMapping(value = "/DoctorDeletePrescriptions")
    public ResponseResultApp doctorDeletePrescriptions(DoctorDeletePrescriptionsDto dto) {
        return doctorConsultStageService.doctorDeletePrescriptions(dto);
    }

    /**
     * @param member_id  用户id
     * @param page_index 起始页
     * @param page_size  条数
     * @param condition  查询条件，目前测试看查询了booking的code模糊
     * @return
     */
    @ApiOperation("获取当前咨询患者的以往咨询数据")
    @GetMapping(value = "/GetComboboxUpConsult")
    public ResponseResultApp<GetComboboxUpConsultVo> getComboboxUpConsult(String member_id, Integer page_index, Integer page_size, String condition) {
        return doctorConsultStageService.getComboboxUpConsult(member_id, page_index, page_size, condition);
    }

    @ApiOperation("获取患者的默认地址")
    @GetMapping(value = "/GetDefaultAddressOfPatient")
    public ResponseResultApp<GetDefaultAddressOfPatientVo> getDefaultAddressOfPatient(String member_id) {
        return doctorConsultStageService.getDefaultAddressOfPatient(member_id);
    }

    /**
     * @param search_text 模糊查询条件
     * @param country_id  国家ID
     * @return
     */
    @ApiOperation("按国家/地区获取诊断")
    @GetMapping(value = "/GetDiagnosisByCountry")
    public ResponseResultApp<List<GetDiagnosisByCountryVo>> getDiagnosisByCountry(String search_text, String country_id) {
        return doctorConsultStageService.getDiagnosisByCountry(search_text, country_id);
    }

    @ApiOperation("获取诊断排除")
    @GetMapping(value = "/GetDiagnosisExclusion")
    public ResponseResultApp<List<GetDiagnosisExclusionVo>> getDiagnosisExclusion(String bookingId) {
        return doctorConsultStageService.getDiagnosisExclusion(bookingId);
    }

    @ApiOperation("医生获得最喜欢的处方")
    @GetMapping(value = "/GetFavouritePrescription")
    public ResponseResultApp<List<GetFavouritePrescriptionVo>> getFavouritePrescription() {
        return doctorConsultStageService.getFavouritePrescription();
    }

    @ApiOperation("医生获得最喜欢的处方详情")
    @GetMapping(value = "/GetFavouritePresciptionDetail")
    public ResponseResultApp<List<GetFavouritePresciptionDetailVo>> getFavouritePresciptionDetail(String favouritePrescriptionId) {
        return doctorConsultStageService.getFavouritePresciptionDetail(favouritePrescriptionId);
    }

    @ApiOperation("更新文本模板")
    @PostMapping(value = "/UpdateTextTemplate")
    public ResponseResultApp<UpdateTextTemplateVo> updateTextTemplate(UpdateTextTemplateDto dto) {
        return doctorConsultStageService.updateTextTemplate(dto);
    }

    @ApiOperation("更新状态涵盖的诊断")
    @PostMapping(value = "/UpdateStatusCoveredDiagnosis")
    public ResponseResultApp updateStatusCoveredDiagnosis(UpdateStatusCoveredDiagnosisDto dto) {
        return doctorConsultStageService.updateStatusCoveredDiagnosis(dto);
    }

    @ApiOperation("更新处方以供审批")
    @PostMapping(value = "/UpdatePrescriptionForApproval")
    public ResponseResultApp updatePrescriptionForApproval(UpdatePrescriptionForApprovalDto dto) {
        return doctorConsultStageService.updatePrescriptionForApproval(dto);
    }

    @ApiOperation("更新问诊处方")
    @PostMapping(value = "/UpdatePrescription")
    public ResponseResultApp updatePrescription(UpdatePrescriptionDto dto) {
        return doctorConsultStageService.updatePrescription(dto);
    }

    @ApiOperation("问诊时医生修改患者Nric")
    @PostMapping(value = "/UpdateNricFin")
    public ResponseResultApp updateNricFin(UpdateNricFinDto dto) {
        return doctorConsultStageService.updateNricFin(dto);
    }

    @ApiOperation("问诊时更新服务列表")
    @PostMapping(value = "/UpdateMedicalService")
    public ResponseResultApp updateMedicalService(UpdateMedicalServiceDto dto) {
        return doctorConsultStageService.updateMedicalService(dto);
    }

    @ApiOperation("修改患者位置")
    @PostMapping(value = "/UpdateLocationForIndonesia")
    public ResponseResultApp updateLocationForIndonesia(UpdateLocationForIndonesiaDto dto) {
        return doctorConsultStageService.updateLocationForIndonesia(dto);
    }

    @ApiOperation("修改问诊患者的性别")
    @PostMapping(value = "/UpdateGender")
    public ResponseResultApp updateGender(UpdateGenderDto dto) {
        return doctorConsultStageService.updateGender(dto);
    }

    @ApiOperation("修改诊断")//实际上只是新增操作 - 删除诊断应该是有别的接口，医生端也并没有编辑，只有删除和新增诊断
    @PostMapping(value = "/UpdateDiagnosis")
    public ResponseResultApp updateDiagnosis(UpdateDiagnosisDto dto) {
        return doctorConsultStageService.updateDiagnosis(dto);
    }

    @ApiOperation("UpdateConSultationNote")
    @PostMapping(value = "/UpdateConSultationNote")
    public ResponseResultApp updateConSultationNote(UpdateConSultationNoteDto dto) {
        return doctorConsultStageService.updateConSultationNote(dto);
    }

    @ApiOperation("UpdateComposition")
    @PostMapping(value = "/UpdateComposition")
    public ResponseResultApp<UpdateCompositionVo> updateComposition(UpdateCompositionDto dto) {
        return doctorConsultStageService.updateComposition(dto);
    }

    @ApiOperation("在医生问诊结束之后的历史记录中修改CDMP的状态")
    @PostMapping(value = "/UnEnrollCdmp")
    public ResponseResultApp unEnrollCdmp(UnEnrollCdmpDto dto) {
        return doctorConsultStageService.unEnrollCdmp(dto);
    }

    @ApiOperation("SubmitPHQ4")
    @PostMapping(value = "/SubmitPHQ4")
    public ResponseResultApp submitPHQ4(SubmitPHQ4Dto dto) {
        return doctorConsultStageService.submitPHQ4(dto);
    }
    @ApiOperation("TriggerInitESDiagnosis")
    @GetMapping(value = "/TriggerInitESDiagnosis")
    public ResponseResultApp triggerInitESDiagnosis() {
        //todo 对方这里操作的es - 先返回成功即可 - 后续确认是否需要
        return ResponseResultApp.success();
    }

    @ApiOperation("StartTBTCConsulation")
    @PostMapping(value = "/StartTBTCConsulation")
    public ResponseResultApp startTBTCConsulation(StartTBTCConsulationDto dto) throws ParseException {
        return doctorConsultStageService.startTBTCConsulation(dto);
    }

    @ApiOperation("ShowPrescriptionToPatient")
    @PostMapping(value = "/ShowPrescriptionToPatient")
    public ResponseResultApp showPrescriptionToPatient(ShowPrescriptionToPatientDto dto){
        return doctorConsultStageService.showPrescriptionToPatient(dto);
    }

    @ApiOperation("SendFirstTBTCMessage")
    @PostMapping(value = "/SendFirstTBTCMessage")
    public ResponseResultApp<SendFirstTBTCMessageVo> sendFirstTBTCMessage(SendFirstTBTCMessageDto dto) throws ParseException {
        return doctorConsultStageService.sendFirstTBTCMessage(dto);
    }

    @ApiOperation("SaveLongTerm")
    @PostMapping(value = "/SaveLongTerm")
    public ResponseResultApp saveLongTerm(SaveLongTermDto dto) {
        return doctorConsultStageService.saveLongTerm(dto);
    }

    @ApiOperation("SaveDrugAlergy")
    @PostMapping(value = "/SaveDrugAlergy")
    public ResponseResultApp saveDrugAlergy(SaveDrugAlergyDto dto) {
        return doctorConsultStageService.saveDrugAlergy(dto);
    }

    @ApiOperation("ReplacePrescription")
    @PostMapping(value = "/ReplacePrescription")
    public ResponseResultApp replacePrescription(ReplacePrescriptionDto dto) {
        return doctorConsultStageService.replacePrescription(dto);
    }

    @ApiOperation("RepeatDiagnosisAndMedication")
    @PostMapping(value = "/RepeatDiagnosisAndMedication")
    public ResponseResultApp repeatDiagnosisAndMedication(RepeatDiagnosisAndMedicationDto dto) {
        return doctorConsultStageService.repeatDiagnosisAndMedication(dto);
    }

    @ApiOperation("RequestFileFromPatient")
    @GetMapping(value = "/RequestFileFromPatient")
    public ResponseResultApp requestFileFromPatient(String booking_id) {
        return doctorConsultStageService.requestFileFromPatient(booking_id);
    }

    @ApiOperation("UpdateDiagnosisAllowPatientToClaim")
    @PostMapping(value = "/UpdateDiagnosisAllowPatientToClaim")
    public ResponseResultApp updateDiagnosisAllowPatientToClaim(UpdateDiagnosisAllowPatientToClaimDto dto) {
        return doctorConsultStageService.updateDiagnosisAllowPatientToClaim(dto);
    }

    @ApiOperation("StartConsulation")
    @PostMapping(value = "/StartConsulation")
    public ResponseResultApp startConsulation(StartConsulationDto dto) throws ParseException {
        return doctorConsultStageService.startConsulation(dto);
    }


}
